package com.ruoyi.consumer.service;

import com.github.binarywang.wxpay.exception.WxPayException;
import com.ruoyi.consumer.domain.PaymentRecordRefund;
import com.ruoyi.consumer.domain.query.WechatPayQuery;
import com.ruoyi.consumer.domain.vo.WeChatUnifiedOderVo;

/**
 * 微信支付实现类
 * @author lisongtao
 * @date 2023/11/7 23:49
 */
public interface IWechatPayService {


    /**
     * 微信支付预支付订单
     */
    WeChatUnifiedOderVo unifiedOrder(WechatPayQuery payQuery) throws WxPayException;

    /**
     * 微信支付回调
     * 判断状态当前订单是否为支付成功
     * 将支付成功的记录设置在redis中
     * 解密获取到支付成功的唯一订单id，将次记录设置为支付成功，软删掉当前订单其他的支付中记录
     *
     * @author lisongtao
     * @date 2023/11/8 23:27
     * @param xmlData
     * @return
     */
    void weChatPayNotify(String xmlData) throws WxPayException;


    /**
     * 轮询支付记录
     * @author lisongtao
     * @date 2023/11/9 23:30
     */
    void pollPaymentRecords();


    /**
     * 查询订单状态
     * @author lisongtao
     * @date 2023/11/13 22:49
     */
    void queryUnderPayOrder(String planId) throws WxPayException;

    /**
     * 取消支付，删除redis记录
     * @author lisongtao
     */
    void closeOrder(String outTradeNo, String type) throws WxPayException;

    /**
     * 退款接口
     */
    void refund(PaymentRecordRefund paymentRecordRefund) throws WxPayException;


}
